import java.io.*;
import java.net.*;

public class Server {
  public static void main(String[] args) throws IOException {
    ServerSocket serverSocket = new ServerSocket(9999);

    while (true) {
      // Blocks until a connection is received.
      Socket client = serverSocket.accept();
      ServerThread thread = new ServerThread(client);

      thread.start();
    }
  }
}

class ServerThread extends Thread {
  private Socket client;

  public ServerThread(Socket client) {
    this.client = client;
  }

  public void run() {
    try {
      System.out.println("Accepted connection");

      DataInputStream is = new DataInputStream(client.getInputStream());
      DataOutputStream os = new DataOutputStream(client.getOutputStream());

      int num = is.readInt();

      os.writeDouble(Math.sqrt(num));

      os.close();
      is.close();

      client.close();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}
